﻿using System.Collections.Generic;
using System.Web.UI.WebControls;
using QuickORM.BLL;
using QuickORM.Entity;

namespace QuickORM.Common
{
    public class KYUtil
    {
        public static int GetDicID(string type, string name)
        {
            var dicList = new List<T_DataDictionary>();
            dicList = BLLFactory<T_DataDictionaryManager>.
                Instance.Find(string.Format("DictionaryType='{0}' and DictionaryName='{1}'", type, name));
            if (dicList.Count != 1)
            {
                return -1;
            }
            return dicList[0].DictionaryID;
        }

        public static string GetDicNameById(int id)
        {
            var dicList = new List<T_DataDictionary>();
            dicList = BLLFactory<T_DataDictionaryManager>.
                Instance.Find(string.Format("DictionaryID='{0}' ", id));
            if (dicList.Count != 1)
            {
                return "";
            }
            return dicList[0].DictionaryName;
        }
    }
}